package cn.cdeden.knowledge.domain;

import cn.cdeden.common.core.utils.StringUtils;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.*;
//import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
* @author GW
* @date 2024-01-19
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("sys_doc_log")
public class SysDocLog implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type= IdType.AUTO)
    private Long id;

//    @ApiModelProperty(value = "操作者")
    private Long operatorId;

//    @ApiModelProperty(value = "企业文档/团队文档")
    private String documentType;

//    @ApiModelProperty(value = "操作类型")
    private String operationType;

//    @ApiModelProperty(value = "文档id")
    private String documentId;

//    @ApiModelProperty(value = "文档类型")
    private String documentName;

//    @ApiModelProperty(value = "文档路径")
    private String documentPath;

//    @ApiModelProperty(value = "文档状态")
    private String documentStatus;

//    @ApiModelProperty(value = "拥有者编号")
    @TableField(fill= FieldFill.INSERT)
    private String createId;

//    @ApiModelProperty(value = "创建者")
    @TableField(fill= FieldFill.INSERT)
    private String createBy;

//    @ApiModelProperty(value = "创建日期")
    @TableField(fill= FieldFill.INSERT)
    private Date createTime;


//    @ApiModelProperty(value = "创建部门id")
    private Long operatorDept;
    public SysDocLog(Long operatorId, String documentId, String documentType, String operationType, String documentName, String documentPath, String documentStatus, Long operatorDept) {
        this.operatorId = operatorId;
        this.documentId = documentId;
        this.documentType = documentType;
        this.operationType = operationType;
        this.documentName = documentName;
        this.documentPath = documentPath;
        this.documentStatus = documentStatus;
        if (StringUtils.isNullOrBlank(documentStatus))this.documentStatus = "正常";
        else if (documentStatus.equals("1") )this.documentStatus = "删除至一级回收站";
        else if (documentStatus.equals("2"))this.documentStatus = "删除至二级回收站";
        else if (documentStatus.equals("3"))this.documentStatus = "彻底删除";
        this.operatorDept = operatorDept;
    }

    public void copyFrom(SysDocLog source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
